#!/bin/bash
#更换YUM
rm -rf /opt/yum
mkdir -p /opt/yum/
mv /etc/yum.repos.d/* /opt/yum/ #备份默认源
echo '[base]
name=CentOS-$releasever - Base - mirrors.huaweicloud.com
failovermethod=priority
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/os/$basearch/
        http://mirrors.huaweicloud.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.huaweicloud.com
failovermethod=priority
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/updates/$basearch/
        http://mirrors.huaweicloud.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.huaweicloud.com
failovermethod=priority
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/
        http://mirrors.huaweicloud.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.huaweicloud.com
failovermethod=priority
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.huaweicloud.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.huaweicloud.com
failovermethod=priority
baseurl=https://mirrors.huaweicloud.com/centos/$releasever/contrib/$basearch/
        http://mirrors.huaweicloud.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7' > /etc/yum.repos.d/Centos-7.repo
echo '[openstack]
name=aliyun_openstack
baseurl=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-stein/
gpgcheck=0
enabled=1' > /etc/yum.repos.d/openstak.repo 
echo '[mongodb-org] 
name=MongoDB Repository
baseurl=https://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/4.0/x86_64/
gpgcheck=0
enabled=1 
#gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc' > /etc/yum.repos.d/mongodb-org.repo 
yum clean all
yum makecache
sh openstack/Y #回到主菜单

